function toGujia() {
    window.location.hash= '#ershoufabupage'
}
function toChengjiao() {
    window.location.hash= '#chachengjiaoPage'
}
$('#ershoufabupage').load(function () {
    $('.ershou-fabu').click(function () {
        try {
            var dict = new RssDict($('#ershou-fabu-form').serializeArray()).keymyid().getDict();
            ValidatedV4(dict).isMobphone('telphone', '手机号格式错误').isNotEmpty('linkman', '联系人必填');
            RssApi.Table.Append('ershoujixie').setLoading().keyvalue($('#ershou-fabu-form').serializeArray()).keymyid().getJson(function (json) {
                console.info(json, 'json');
                if (json.id) {
                    alert('发布成功');
                    window.location.href = 'index.html';
                } else {
                    alert('发布失败');
                }
            })
        } catch (err) {
            alert(err);
        }
    })
})

$('#hotPage').load(function () {
    getHotPageList()
})
function getHotPageList() {
    const dict = { classifyid: $('input[name=ershou-classfiyid]').val(), trademarklid: $('input[name=ershou-trademarklid]').val()};
    RssApi.Table.List('ershoujixie').condition(dict).getJson(function (data, json) {
        if(data.length === 0) {
            $('.needList-no-list').removeClass('hide');
        } else {
            $('.needList-no-list').addClass('hide');
        }
        $.each(data, function (idx, rows) {
            rows['classifyid'] = getClassfiyid(rows.trademarklid) + '-' +getClassfiyid(rows.classifyid);
            rows['shijian'] = formatTest(rows.shijian);
        })
        $('.wrap-hotpage').maplist(data).find('>div').click(function () {
            toershouOrder($(this).attr('rssid'));
        });
    })
}
function toershouOrder(id) {
    console.info(id);
    localStorage.ershouid = id;
    window.location.hash = "#erhsou-order";
}
$('#erhsou-order').load(function () {
    $('.w-help').click(function () {
        $('.myNeed-wrap-help').show();
        $('.myNeed-wrap-help').removeClass('hide');
        $('.myNeed-wrap-content,.wrap-need-button').hide();
    })
    $(".tab>div").click(function () {
        $(this).addClass('active');
        $('.myNeed-wrap-help').hide();
        $('.myNeed-wrap-content,.wrap-need-button').show();
        $(this).siblings().removeClass('active');
    })
    RssApi.Table.Detail('ershoujixie').condition({ id: localStorage.ershouid }).keymyid().getJson(function (data, json) {
        console.info(data,'xxx');
        $('.myneed-classfiy').text(getClassfiyid(data.classifyid));
        $('.myneed-trademarklid').text(getTrademarklid(data.trademarklid));
        $('.myneed-approachtime').text(data.usetime);
        $('.myneed-commission').text(isYes(data.iscommission));
        $('.myneed-clearingform').text(isYes(data.isziying));
    })
    $('.baojia').click(function () {
        $('.toast-bg').removeClass('hide');
    })
    $('.confirm').click(function () {
        appendOrder();
    })
})